using System.Data;

namespace QueryBuilder.Core.Query
{
    /// <summary>
    /// 
    /// </summary>
    public class Column : Constraint, IColumn
    {
        #region IColumn Members

        /// <summary>
        /// Initializes a new instance of the <see cref="Column"/> class.
        /// </summary>
        public Column()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Column"/> class.
        /// </summary>
        /// <param name="table">The table.</param>
        /// <param name="name">The name.</param>
        public Column(ITable table, string name)
        {
            this.Name = name;
            this.Table = table;
        }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        /// <value>The name.</value>
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets the name of the schema.
        /// </summary>
        /// <value>The name of the schema.</value>
        public string SchemaName { get; set; }

        /// <summary>
        /// Gets or sets the type of the data.
        /// </summary>
        /// <value>The type of the data.</value>
        public DbType DataType { get; set; }

        /// <summary>
        /// Gets or sets the foreign key to.
        /// </summary>
        /// <value>The foreign key to.</value>
        public ITable ForeignKeyTo { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is foreign key.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is foreign key; otherwise, <c>false</c>.
        /// </value>
        public bool IsForeignKey { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is primary key.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is primary key; otherwise, <c>false</c>.
        /// </value>
        public bool IsPrimaryKey { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is nullable.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is nullable; otherwise, <c>false</c>.
        /// </value>
        public bool IsNullable { get; set; }

        /// <summary>
        /// Gets or sets the table.
        /// </summary>
        /// <value>The table.</value>
        public ITable Table { get; set; }

        #endregion

        /// <summary>
        /// Accepts the specified constraint presenter.
        /// </summary>
        /// <param name="constraintPresenter">The constraint presenter.</param>
        public override void Accept(IConstraintPresenter constraintPresenter)
        {
            constraintPresenter.Present(this);
        }
    }
}